const request = require('request');
const express = require("express");
var server=express();
server.listen(8088,function(){
    console.log(`listener:${8088}`)
})
var json={
    name:"gouzi",
    age:"22",
}
server.get("/*",function(req,res){
   var  str=  req.url;

    /*解决ajax跨域问题*/
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'Content-Type,Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
    res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE,OPTIONS');
    ;
    request(`http://${str}`, function (error, response, body) {
        if (!error && response.statusCode == 200) {
            res.send(body);
            console.log(body) // 打印google首页
            res.end();
        }
    })


})
/*
var express = require('express');
var app = express();

app.get('/', function (req, res) {
    res.send('Hello World');
})

var server = app.listen(8081, function () {

    var host = server.address().address
    var port = server.address().port

    console.log("应用实例，访问地址为 http://%s:%s", host, port)

})*/
